/*
 * clickcheckout.java
 *
 * Created on March 26, 2007, 7:11 AM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */
package edu.byu.isys413.actions;
import javax.servlet.http.*;
import edu.byu.isys413.group1E.data.*;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
/**This action takes the user to the "Make Prints" webpage, and creates a blank prints transaction
 *
 * @author Kendall Frazier
 */
public class printhome implements edu.byu.isys413.web.Action {
    
    /**
     * Creates a new instance of clickcheckout
     */
    public printhome() {
    }
    
    /** 
     *Processes this method is called when the user wants to order some prints.  So when "order Prints" is pressed from the
     *main screen.  A new, blank, print transaction is created at this point, and saved over the old transaction in the session
     *
     *
     *@param HttpServletRequest
     *@param HttpServletResponse
     *
     *@return String the name of the jsp to call
     */
    public String process(HttpServletRequest request, HttpServletResponse response) throws Exception {
        HttpSession session = request.getSession();
        
  //this is the precident for clearing the transaction
        TransactionDAO TXDAO = TransactionDAO.getInstance();
        TransactionBO TXBO = TXDAO.create();
        CustomerBO customer = (CustomerBO)session.getAttribute("customer");
        TXBO.setCustomerID(customer.getCustID());        
        TXBO.setStoreID("0000011106a3cc370000007f000002");
        TXBO.setEmployeeID("0000011106a3cc390000007f000002");
        //set the date for the transaction
        Calendar cal = Calendar.getInstance();
        Date today = cal.getTime();
        SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd");
        String todayDate = fmt.format(today);
        TXBO.setTransDate(todayDate);
        
        session.setAttribute("TX", TXBO);
        
        return "print.jsp";
    }//process
    
    
}//clickcheckout class
